import 'package:dio/dio.dart';

class HttpResponseModel {
  int? code = 0; //接口返回的code
  bool isSuccess = false; //请求成功,业务成功
  bool isFail = false; //连接成功,业务失败
  bool isError = false; //http请求错误
  int? statusCode = 0; //http StatusCode
  String? message = ""; //接口返回信息或者错误信息
  dynamic data; //接口返回数据
  bool hasMore = false; //分页判断; ！暂不可使用！！
  Response? response; //请求失败时带上接口返回的response

  //response的请求头
  late Headers _headers;
  Headers get headers => _headers;
  set headers(Headers headers) {
    _headers = headers;
    if (headers.isEmpty == false) {
      // String? token = headers.value("hxfw-token");
      // String? expired = headers.value("hxfw-login-expired");
      // NativeChannel.updateToken(token, expired);
    }
  }

  //获取数组数据
  List get dataList => (data is List
      ? data ?? []
      : data is Map
          ? (data["entityList"] ?? [])
          : []);

// //TODO:暂无处理
// bool getHasMore() {
//   if (this.data is Map) {
//     int total = this.data["total"];
//     int rowSize = this.data["rowSize"];
//     int rowCount = this.data["rowCount"]; //当前页
//     return (total - rowSize * rowCount > 0);
//   } else {
//     return this.hasMore;
//   }
// }
}
